﻿''' <summary>
''' Provide access to the PDF viewer preferences properties
''' </summary>
''' <remarks>Viewer preferences specifying the way the document is to be displayed on the screen.
''' If this entry is absent, applications should use their own current user preference settings.</remarks>
Public Class clsPDFViewerPreferences
    Inherits clsPdfDictionnary
    Private _catalog As clsPdfDictionnary   'The catalog dictionnary contains some viewer preferences
#Region "Constructors"
    Friend Sub New(ByVal dict As Hashtable, catalog As clsPdfDictionnary)
        MyBase.New(dict)
        _catalog = catalog
    End Sub
    Friend Sub New(catalog As clsPdfDictionnary)
        MyBase.New()
        _catalog = catalog
    End Sub
#End Region
#Region "Public Properties"
    ''' <summary>
    ''' Page layout to be used when the document is opened
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: SinglePage</remarks>
    Public Property PageLayout As PageLayoutTypes
        'This value is stored in the catalog object
        Get
            Dim s As String

            If _catalog.ContainsKey(PDF_PAGELAYOUT) Then
                s = _catalog.GetString(PDF_PAGELAYOUT)

                Select Case s
                    Case PDF_SINGLEPAGE
                        PageLayout = PageLayoutTypes.SinglePage
                    Case PDF_ONECOLUMN
                        PageLayout = PageLayoutTypes.OneColumn
                    Case PDF_TWOCOLUMNLEFT
                        PageLayout = PageLayoutTypes.TwoColumnLeft
                    Case PDF_TWOCOLUMNRIGHT
                        PageLayout = PageLayoutTypes.TwoColumnRight
                    Case PDF_TWOPAGELEFT
                        PageLayout = PageLayoutTypes.TwoPageLeft
                    Case PDF_TWOPAGERIGHT
                        PageLayout = PageLayoutTypes.TwoPageRight
                    Case Else
                        PageLayout = PageLayoutTypes.Unknown
                End Select
            Else
                'Default value
                PageLayout = PageLayoutTypes.SinglePage
            End If
        End Get
        Set(value As PageLayoutTypes)
            _catalog.Add(PDF_PAGELAYOUT, CreateNameObject(value.ToString), True)
            _catalog.Modified()
        End Set
    End Property
    ''' <summary>
    ''' Specify how the document should be displayed when opened
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: UseNone</remarks>
    Public Property PageMode As PageModeTypes
        'This value is stored in the catalog object
        Get
            Dim s As String

            If _catalog.ContainsKey(PDF_PAGEMODE) Then
                s = _catalog.GetString(PDF_PAGEMODE)

                Select Case s
                    Case PDF_USENONE
                        PageMode = PageModeTypes.UseNone
                    Case PDF_USEOUTLINES
                        PageMode = PageModeTypes.UseOutlines
                    Case PDF_USETHUMBS
                        PageMode = PageModeTypes.UseThumbs
                    Case PDF_FULLSCREEN
                        PageMode = PageModeTypes.FullScreen
                    Case PDF_USEOC
                        PageMode = PageModeTypes.UseOC
                    Case PDF_USEATTACHEMENTS
                        PageMode = PageModeTypes.UseAttachments
                    Case Else
                        PageMode = PageModeTypes.Unknown
                End Select
            Else
                'Default value
                PageMode = PageModeTypes.UseNone
            End If

        End Get
        Set(value As PageModeTypes)
            _catalog.Add(PDF_PAGEMODE, CreateNameObject(value.ToString), True)
            _catalog.Modified()
        End Set
    End Property
    ''' <summary>
    ''' A flag specifying whether to hide the viewer application’s tool bars when the document is active
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: false</remarks>
    Public Property HideToolbar() As Boolean
        Get
            If ContainsKey(PDF_HIDETOOLBAR) Then
                HideToolbar = GetBoolean(PDF_HIDETOOLBAR)
            Else
                'Default value
                HideToolbar = False
            End If
        End Get
        Set(ByVal value As Boolean)
            Add(PDF_HIDETOOLBAR, CreateBooleanObject(value), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' A flag specifying whether to hide the viewer application’s menu bar when the document is active.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: false</remarks>
    Public Property HideMenubar() As Boolean
        Get
            If ContainsKey(PDF_HIDEMENUBAR) Then
                HideMenubar = GetBoolean(PDF_HIDEMENUBAR)
            Else
                'Default value
                HideMenubar = False
            End If
        End Get
        Set(ByVal value As Boolean)
            Add(PDF_HIDEMENUBAR, CreateBooleanObject(value), True)
            Modified()
        End Set
    End Property
    Public Property HideWindowUI() As Boolean
        Get
            If ContainsKey(PDF_HIDEWINDOWUI) Then
                HideWindowUI = GetBoolean(PDF_HIDEWINDOWUI)
            Else
                'Default value
                HideWindowUI = False
            End If
        End Get
        Set(ByVal value As Boolean)
            Add(PDF_HIDEWINDOWUI, CreateBooleanObject(value), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' A flag specifying whether to position the document’s window in the center of the screen
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: false</remarks>
    Public Property CenterWindow() As Boolean
        Get
            If ContainsKey(PDF_CENTERWINDOW) Then
                CenterWindow = GetBoolean(PDF_CENTERWINDOW)
            Else
                'Default value
                CenterWindow = False
            End If
        End Get
        Set(ByVal value As Boolean)
            Add(PDF_CENTERWINDOW, CreateBooleanObject(value), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' A flag specifying whether to resize the document’s window to fit the size of the first displayed page
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: false</remarks>
    Public Property FitWindow() As Boolean
        Get
            If ContainsKey(PDF_FITWINDOW) Then
                FitWindow = GetBoolean(PDF_FITWINDOW)
            Else
                'Default value
                FitWindow = False
            End If
        End Get
        Set(ByVal value As Boolean)
            Add(PDF_FITWINDOW, CreateBooleanObject(value), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' A flag specifying whether the window’s title bar should display the document title taken from the DocumentInformation object.
    ''' If false, the title bar should instead display the name of the PDF file containing the document
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: false</remarks>
    Public Property DisplayDocTitle() As Boolean
        Get
            If ContainsKey(PDF_DISPLAYDOCTITLE) Then
                DisplayDocTitle = GetBoolean(PDF_DISPLAYDOCTITLE)
            Else
                'Default value
                DisplayDocTitle = False
            End If
        End Get
        Set(ByVal value As Boolean)
            Add(PDF_DISPLAYDOCTITLE, CreateBooleanObject(value), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' A flag specifying whether the PDF page size is used to select the input paper tray. 
    ''' This setting influences only the preset values used to populate the print dialog presented by a PDF viewer application.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>If PickTrayByPDFSize is true, the check box in the print dialog associated with input paper tray is checked.
    ''' This setting has no effect on Mac OS systems, which do not provide the ability to pick the input tray by size.</remarks>
    Public Property PickTrayByPDFSize() As Boolean
        Get
            If ContainsKey(PDF_PICKTRAYBYPDFSIZE) Then
                PickTrayByPDFSize = GetBoolean(PDF_PICKTRAYBYPDFSIZE)
            Else
                'Default value
                PickTrayByPDFSize = False
            End If
        End Get
        Set(ByVal value As Boolean)
            Add(PDF_PICKTRAYBYPDFSIZE, CreateBooleanObject(value), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' The number of copies to be printed when the print dialog is opened for this file. 
    ''' Supported values are the integers 2 through 5. Values outside this range are ignored.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: as defined by PDF viewer application, but typically 1</remarks>
    Public Property NumCopies() As Integer
        Get
            If ContainsKey(PDF_NUMCOPIES) Then
                NumCopies = GetLong(PDF_NUMCOPIES)
            Else
                'Default value
                NumCopies = 1
            End If
        End Get
        Set(ByVal value As Integer)
            Add(PDF_NUMCOPIES, CreateNumericObject(value), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' The page scaling option to be selected when a print dialog is displayed for this document
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>If this entry has an unrecognized value, applications should use the current print scaling
    ''' Default value: AppDefault</remarks>
    Public Property PrintScaling As PrintScalingTypes
        Get
            Dim s As String
            If ContainsKey(PDF_PRINTSCALING) Then
                s = GetString(PDF_PRINTSCALING)
                Select Case s
                    Case PDF_NONE
                        PrintScaling = PrintScalingTypes.None
                    Case PDF_APPDEFAULT
                        PrintScaling = PrintScalingTypes.AppDefault
                    Case Else
                        PrintScaling = PrintScalingTypes.Unknown
                End Select
            Else
                'Default Value
                PrintScaling = PrintScalingTypes.AppDefault
            End If
        End Get
        Set(value As PrintScalingTypes)
            Add(PDF_PRINTSCALING, CreateNameObject(value.ToString), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' The predominant reading order for text
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>This entry has no direct effect on the document’s contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up</remarks>
    Public Property Direction As DirectionReadingTypes
        Get
            Dim s As String
            If ContainsKey(PDF_DIRECTION) Then
                s = GetString(PDF_DIRECTION)
                Select Case s
                    Case PDF_DIRECTION_L2R
                        Direction = DirectionReadingTypes.L2R
                    Case PDF_DIRECTION_R2L
                        Direction = DirectionReadingTypes.R2L
                    Case Else
                        Direction = DirectionReadingTypes.L2R
                End Select
            Else
                'Default value
                Direction = DirectionReadingTypes.L2R
            End If
        End Get
        Set(value As DirectionReadingTypes)
            Add(PDF_DIRECTION, CreateNameObject(value.ToString), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' The document’s page mode, specifying how to display the document on exiting full-screen mode:
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>This entry is meaningful only if the value of the PageMode entry in the catalog is FullScreen; it is ignored otherwise. Default value: UseNone.</remarks>
    Public Property NonFullScreenPageMode As NonFullScreenPageModeTypes
        Get
            Dim s As String
            If ContainsKey(PDF_NONFULLSCREENPAGEMODE) Then
                s = GetString(PDF_NONFULLSCREENPAGEMODE)
                Select Case s
                    Case PDF_USENONE
                        NonFullScreenPageMode = NonFullScreenPageModeTypes.UseNone
                    Case PDF_USEOUTLINES
                        NonFullScreenPageMode = NonFullScreenPageModeTypes.UseOutlines
                    Case PDF_USETHUMBS
                        NonFullScreenPageMode = NonFullScreenPageModeTypes.UseThumbs
                    Case PDF_USEOC
                        NonFullScreenPageMode = NonFullScreenPageModeTypes.UseOC
                    Case Else
                        NonFullScreenPageMode = NonFullScreenPageModeTypes.Unknown
                End Select
            Else
                'Default value
                NonFullScreenPageMode = NonFullScreenPageModeTypes.UseNone
            End If
        End Get
        Set(value As NonFullScreenPageModeTypes)
            Add(PDF_NONFULLSCREENPAGEMODE, CreateNameObject(value.ToString), True)
            Modified()
        End Set
    End Property
    ''' <summary>
    ''' The paper handling option to use when printing the file from the print dialog
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Default value: none</remarks>
    Public Property Duplex As DuplexTypes
        Get
            Dim s As String
            If ContainsKey(PDF_DUPLEX) Then
                s = GetString(PDF_DUPLEX)
                Select Case s
                    Case PDF_SIMPLEX
                        Duplex = DuplexTypes.Simplex
                    Case PDF_DUPLEXFLIPSHORTEDGE
                        Duplex = DuplexTypes.DuplexFlipShortEdge
                    Case PDF_DUPLEXFLIPLONGEDGE
                        Duplex = DuplexTypes.DuplexFlipLongEdge
                    Case Else
                        Duplex = DuplexTypes.Unknown
                End Select
            Else
                Duplex = DuplexTypes.Unknown
            End If
        End Get
        Set(value As DuplexTypes)
            Add(PDF_DUPLEX, CreateNameObject(value.ToString), True)
            Modified()
        End Set
    End Property
#End Region
End Class
